Class symantec.itools.awt.util.Util
All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class symantec.itools.awt.util.Util

Object
   |
   +----symantec.itools.awt.util.Util

public class Util
extends Object
An all-static utility class with handy helper methods to retrieve font information.


Constructor Index

 o symantec.itools.awt.util.Util()
Do not use, all-static class.

Method Index

 o findComponent(Container, Component)
Finds the index of a component in a container.
 o getDefaultFont()
Retrieves a default dialog font.
 o getFontHeight(Graphics)
Determines the height of the font being used by the given graphics context.
 o getFontHeight(Font)
Determines the height of the font specified.
 o getFontHeight(FontMetrics)
Determines the height of the font given the metrics of that font.
 o getGraphics(Image, Component)
Preserves the font information of a graphics object retrieved from an image.
 o getStringWidth(Graphics, String)
Determines the width of the given string if it were drawn using the specified graphics context.
 o getStringWidth(Font, String)
Determines the width of the given string if it were drawn using the specified font.
 o getStringWidth(FontMetrics, String)
Determines the width of the given string if it were drawn in a font with the specified metrics.

Constructors

 o Util
public Util()
Do not use, all-static class.

Methods

 o findComponent
public static int findComponent(Container container,
                                Component component)
Finds the index of a component in a container.

Parameters:
container - the container to search
component - the component to find
Returns:
the zero-relative component index, or -1 if the component is not found in the container
 o getDefaultFont
public static java.awt.Font getDefaultFont()
Retrieves a default dialog font. In this case the typeface is a plain 12-point ôDialogö.

Returns:
the default dialog font
 o getFontHeight
public static int getFontHeight(Graphics g)
Determines the height of the font being used by the given graphics context. This is the standard height of a line of text in the font.

Parameters:
g - a graphics context
Returns:
the font height, in pixels
 o getFontHeight
public static int getFontHeight(Font f)
Determines the height of the font specified. This is the standard height of a line of text in the font.

Parameters:
f - the font
Returns:
the font height, in pixels
 o getFontHeight
public static int getFontHeight(FontMetrics m)
Determines the height of the font given the metrics of that font. This is the standard height of a line of text in the font.

Parameters:
m - the metrics of the font
Returns:
the font height, in pixels
 o getGraphics
public static java.awt.Graphics getGraphics(Image image,
                                            Component component)
Preserves the font information of a graphics object retrieved from an image. This ensures that susequent calls to getFontMetrics through the graphics object will not result in a NullPointerException. It does this by setting the font in the imageÆs graphics context to the font in the component, as needed.

Parameters:
image - the image with the desired graphics context
component - the component
Returns:
a graphics context with a currently set font
 o getStringWidth
public static int getStringWidth(Graphics g,
                                 String s)
Determines the width of the given string if it were drawn using the specified graphics context.

Parameters:
g - the graphics context
s - the string to determine the width of
Returns:
the width of the string, in pixels
 o getStringWidth
public static int getStringWidth(Font f,
                                 String s)
Determines the width of the given string if it were drawn using the specified font.

Parameters:
g - the font
s - the string to determine the width of
Returns:
the width of the string, in pixels
 o getStringWidth
public static int getStringWidth(FontMetrics m,
                                 String s)
Determines the width of the given string if it were drawn in a font with the specified metrics.

Parameters:
m - the font metrics
s - the string to determine the width of
Returns:
the width of the string, in pixels

All Packages  Class Hierarchy  This Package  Previous  Next  Index